<?php

/**
 * Flickr Photosets - Tagged Page
 * Displays photos tagged with a particular user.
 * 
 * @author Brad Dougherty <bdougherty@gmail.com>
 * @version 8.6.3
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License 3.0
 */

/*
Require the function library
This will include all other necessary files
*/
require_once 'lib.php';

/*
Initialize Flickr Photosets and Flickr.
This will create the Flickr object without using the cache.
	(There is still a delay when you tag sometimes, the tag
	is not always immediately available in a search.)
*/
$fp = new FP_ProfileTab();

// Get photos
$photo_page = (isset($_GET['photo_page'])) ? $_GET['photo_page'] : 1;
$fp->page = $photo_page; // So we get the right page of tagged photos
$photos = $fp->get_tagged_photos_of($fp->uid);

?>

<?php //include 'styles.php' ?>
<style type="text/css">

#photos_tab .header { overflow: hidden; padding: 6px 10px; }
#photos_tab .header h3 { color: #333; font-size: 13px; }

#photos_tab #photo_album,
	#photos_tab #set_album { background-color: #ebebeb; border-spacing: 5px; border: 1px solid #ccc; margin-bottom: 20px; }

#photos_tab #photo_album .photo_small { background-color: white; border: 1px solid #ccc; padding: 4px; max-width: 130px; max-height: 130px; }
#photos_tab #photo_album .photo_small:hover { border: 1px solid #3B5998; }
#photos_tab #photo_album .photo_link { margin: 10px 0 10px; vertical-align: middle; }
#photos_tab #photo_album .photo_cell { padding: 10px 0; text-align: center; height: 124px; width: 154px; }

.fppagerpro { display: block; float: right; font-weight: normal; }
.fppagerpro a { padding: 3px 3px 2px; }
.fppagerpro a:hover { color: white; background-color: #3B5998; text-decoration: none; }
.fppagerpro a.disabled { background: transparent none repeat scroll 0% 0%; border: medium none; color: #999; cursor: default; }

</style>

<div id="photos_tab">
	
	<div id="photos_of_me">
		<div class="header">
			<div class="fppagerpro">
				<?php if ($photo_page > 1) {
					echo '<a href="profile_tab.php?photo_page='.($photo_page - 1).'">Previous</a>';
				}
				else {
					echo '<a href="#" class="disabled" onclick="return false;">Previous</a>';
				}
				
				if ($photo_page < $photos['pages']) {
					echo '<a href="profile_tab.php?photo_page='.($fp->page + 1).'">Next</a>';
				}
				else {
					echo '<a href="#" class="disabled" onclick="return false;">Next</a>';
				} ?>
			</div>
			<h3><span style="color:#3e79c0;">Flick<span style="color:#d760a9;">r</span></span> Photos of <fb:name uid="<?=$fp->uid?>" useyou="false" firstnameonly="true" /></h3><span><?=$photos['total']?> photos</span>
		</div>
		
		<table id="photo_album">
			<?php
			$photos_row = 0;
			foreach ($photos['photo'] as $photo): ?>
				
				<?php if ($photos_row < 1) {
					echo '<tr>';
				} ?>
				
				<td class="photo_cell">
					<a href="photos/<?=$fp->get_uid_from_nsid($photo['owner'])?>/<?=$photo['id']?>/of/<?=$fp->uid?>/">
						<?php if ($photo['media'] == 'video') { ?>
							<img src="http://l.yimg.com/www.flickr.com/images/video_play_icon_small.png.v1" class="video_icon" />
						<?php } ?>
						<img class="photo_small photo_link" src="<?=$fp->flickr->buildPhotoUrl($photo, 'small')?>" alt="<?=$photo['title']?>" title="<?=$photo['title']?>" />
					</a>
				</td>
				
				<?php
				$photos_row++;
				
				// End the row
				if ($photos_row >= 5) {
					echo '</tr>';
					$photos_row = 0;
				}
				
				?>
				
			<?php endforeach;
			
			// Make sure we always have 5 cells
			if ($photos_row > 0 and $photos_row < 5) {
				while ($photos_row < 5) {
					echo '<td class="photo_cell"></td>';
					$photos_row++;
				}
			}
			
			?>
		</table>
	</div>
	
</div>